package com.wanmait.meteor.controller;

import com.github.pagehelper.PageInfo;
import com.wanmait.meteor.pojo.MeetType;
import com.wanmait.meteor.pojo.Meetinfo;
import com.wanmait.meteor.service.ConfigService;
import com.wanmait.meteor.service.MeetTypeService;
import com.wanmait.meteor.service.MeetinfoService;
import com.wanmait.meteor.util.IgnoreToken;
import com.wanmait.meteor.util.Result;
import org.apache.tomcat.util.buf.StringUtils;
import org.springframework.beans.factory.support.ManagedList;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

@IgnoreToken
@RestController
@CrossOrigin
@RequestMapping("/manage")
public class ManageMeetController {
    @Resource
    private MeetinfoService meetInfoService;
    @Resource
    private ConfigService configService;
    @Resource
    private MeetTypeService meetTypeService;
   //wf 未使用
    @IgnoreToken
    @GetMapping("/list")
    public Result list(Integer pageNum){
        return null;
    }
    //wf
    //条件查询  通过二级会议类型和会议名关键字查询 并分页
    @IgnoreToken
    @PostMapping("/selectList")
    public Result selectList(Integer pageNum, @RequestBody Meetinfo meetinfo) {
        int pageSize = configService.selectPageSize();
        PageInfo<Meetinfo> pageInfo = meetInfoService.selectList(meetinfo, pageNum, pageSize);
        return Result.success(pageInfo);

    }
    // wf 查找全部二级分类
    @IgnoreToken
    @GetMapping("/selectTypeList")
    public Result selectFirstTypeList(){
    List<MeetType> meetTypes=meetTypeService.selectFirstType();
    return Result.success(meetTypes);
    }

  /*  @PostMapping("batchDelete")
    public Result batchDelete(@RequestBody Integer[] meetinfoIds) {
     *//*   String strMeetinfoIds= StringUtils.join(meetinfoIds, ',');
        meetInfoService.delete(strMeetinfoIds);
        return Result.success("删除成功");*//*

    }
*/
  //wf 删除会议
    @IgnoreToken
    @GetMapping("/delMeetinfo")
    public Result delMeetinfo(Integer id){
        meetInfoService.delMeetinfo(id);
        return Result.success();
    }
    //wf 改变轮播状态
    @IgnoreToken
    @GetMapping("/changeSuffing")
    public Result changeSuffing(Integer id){
        meetInfoService.changeSuffing(id);
        return Result.success();
    }
    //wf 改变审核状态
    @IgnoreToken
    @GetMapping("/changeAudit")
    public Result changeAudit(Integer id){
        meetInfoService.changeAudit(id);
        return Result.success();
    }
    //wf 通过会议ID查找会议
    @IgnoreToken
    @GetMapping("/selectAMeet")
    public Result selectAMeet(Integer id){
       Meetinfo meetinfo= meetInfoService.selectAMeet(id);
        return Result.success(meetinfo);
    }


}

